'''
class Solution {
    public int maxAreaOfIsland(int[][] grid) {
        int res = 0;
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[0].length; j++) {
                if (grid[i][j] == 1){
                    int tmp = dfs(grid, i, j);
                    if (tmp > res){
                        res = tmp;
                    }
                }
            }
        }
        return res;
    }

    int dfs(int[][] grid, int r, int c){
        int row = grid.length;
        int col = grid[0].length;

        if (r < 0 || c < 0 || r >= row || c >= col || grid[r][c] == 0){
            return 0;
        }

        grid[r][c] = 0;

        int left = dfs(grid, r - 1, c);
        int right = dfs(grid, r + 1, c);
        int bottom = dfs(grid, r, c + 1);
        int top = dfs(grid, r, c - 1);

        return left + right + bottom + top + 1;
    }

}
'''

